<template>
  <div
    class="cell"
    @click="clickFn"
  >
    <div class="left">{{ title }}</div>
    <div class="right">{{ value }} <i class="iconfont iconjiantou1"></i></div>
  </div>
</template>

<script>
export default {
  props: {
    title: String,
    value: String,
    to: String,
  },
  methods: {
    clickFn(e) {
      // console.log("你居然点击了子组件");
      // 如果父组件传递了 to 属性，就根据 to 属性跳转路由
      if (this.to) this.$router.push({ path: this.to });
      // 预留给父组件也能添加点击事件
      this.$emit("click", e);
    },
  },
};
</script>

<style lang="less" scoped>
.cell {
  height: 50px;
  font-size: 14px;
  margin: 0 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  // 主轴两端对齐
  justify-content: space-between;
  // 侧轴垂直居中
  align-items: center;
  .right {
    font-size: 13px;
    color: #666;
  }
}
</style>